var db = {};
var mysql = require('mysql');
const Config = require('../Config').DBConfig;
const Util = require('./util')
var pool = mysql.createPool({
    ...Config,
    multipleStatements: true
});




db.query = function (sql, para) {
    return new Promise((resolve, reject) => {
        pool.query(sql, para, function (err, rows, fields) {
            if (err) {
                reject(err);
            } else {
                resolve(Util.formatArray(rows), fields)
            };
        });
    });
}

module.exports = db;